import java.util.Arrays;

public class myStack {
    int usesize;
    int[]elem;
  public static final int size=10;

    public myStack() {
        this.elem =new int[size];
    }
    public int push(int c)
    {
        if(full())
        {
            System.out.println("此时栈已满");
            this.elem= Arrays.copyOf(this.elem,2*size);
        }

        elem[usesize]=c;
        usesize++;
        return c;
    }
    public int peek()
    {
        return elem[usesize-1];
    }
    public int pop()
    {
        if(empty())
        {
            System.out.println("此时栈已空");
        }
        return elem[--usesize];
    }
    public boolean full()
    {
        return usesize==size;
    }
    public boolean empty()
    {
        return usesize==0;
    }
}
class text{
    public static void main(String[] args) {
        myStack a=new myStack();
        a.push(1);
        a.push(2);
        a.push(3);
        a.push(4);
        int b=a.pop();
        System.out.println(b);
        int c=a.peek();
        System.out.println(c);


    }
}
